import random

all_choices = ['石头', '剪刀', '布']
wins = [['石头','剪刀'], ['剪刀', '布'], ['布', '石头']]

pwin = 0
cwin = 0
count = 0

while True:
    count += 1
    print(f'第 {count} 轮开始:')
    computer = random.choice(all_choices)
    player = all_choices[int(input('''请输入：
0 石头
1 剪刀
2 布
'''))]
    if player == computer:
        print(f'第 {count} 轮，玩家出 {player}，电脑出 {computer}，平局')
    elif [player, computer] in wins:
        print(f'第 {count} 轮，玩家出 {player}，电脑出 {computer}，玩家赢')
        pwin += 1
    else:
        print(f'第 {count} 轮，玩家出 {player}，电脑出 {computer}，电脑赢')
        cwin += 1

    if pwin >= 2:
        print('游戏结束，玩家赢：%s:%s' % (pwin,cwin))
        break
    elif cwin >= 2:
        print('游戏结束，电脑赢：%s:%s' % (cwin, pwin))
        break

    print()
